#coding=utf-8
import parameters as pms
import gym
from dqn import *
import tensorflow as tf
def main(_):

    gpu_options = tf.GPUOptions(
        per_process_gpu_memory_fraction=0.5/3.0)
    with tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) as sess:
        env=gym.make(pms.gamename)
        agent=DQNAgent(env,sess,model=pms.model,render=pms.train_render_flag)
        if(pms.train_flag):
           agent.startTrain()
        else:
            for episodeNumber in range(pms.maxSteps):
                state = env.reset()
                done = False
                success_steps=0
                ###采集其中一个场景的数据
                while (done == False):
                    success_steps += 1
                    env.render()
                    actionNum = agent.act(state, 0.0)  # get action
                    # print actionNum
                    state, reward, done, info = env.step(actionNum)
                print 'success_steps:%d'%success_steps

if __name__=='__main__':
    tf.app.run()
